

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>编辑用户</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="__PUBLIC__/style/admin.css" media="all">
</head>
<body>  
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">系统参数配置</div>
          <div class="layui-card-body">
            <div class="layui-form">
              <div class="layui-form-item">
                <label class="layui-form-label">系统名称</label>
                <div class="layui-input-block">
                  <input type="text" name="title" autocomplete="off" placeholder="请输入系统名称" lay-verify="required" class="layui-input" value="{$config.title}">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">系统版本</label>
                <div class="layui-input-block">
                  <input type="text" name="version" autocomplete="off" placeholder="请输入系统版本" lay-verify="required" class="layui-input"  value="{$config.ver}">
                </div>
              </div>
              <hr class="layui-border-green" style="margin: 20px;">
              <blockquote class="layui-elem-quote layui-quote-nm">
                请填写完整的协议类型（如：HTTPS://）。
                <p><span style="color:#1e9fff">脚本地址</span>：嵌入客户端的脚本获取接口</p>
                <p><span style="color:#1e9fff">回传地址</span>：客户端数据上传到服务器的接口</p>
              </blockquote>
              <div class="layui-form-item">
                <label class="layui-form-label">脚本地址</label>
                <div class="layui-input-block">
                  <input type="text" name="getscript" autocomplete="off" placeholder="https://test.com" lay-verify="required" class="layui-input"  value="{$config.getscript}">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">回传地址</label>
                <div class="layui-input-block">
                  <input type="text" name="callback" autocomplete="off" placeholder="https://test.com/IO/Post/index" lay-verify="required" class="layui-input"  value="{$config.callback}">
                </div>
              </div>
              <hr class="layui-border-green" style="margin: 20px;">
              <blockquote class="layui-elem-quote layui-quote-nm">
                配置该模块可以在系统接收到内容时短信通知到手机，测试短信将发送至管理员手机。<br/>
                该模块调用短信宝接口，需要注册并充值，<a href="http://www.smsbao.com/" target='_blank' style="color: #1e9fff;">点击前往</a>。
              </blockquote>
              <div class="layui-form-item">
                <label class="layui-form-label">SMS用户名</label>
                <div class="layui-input-block">
                  <input type="text" name="sms_user" id="sms_user" autocomplete="off" placeholder="请输入用户名" class="layui-input"  value="{$config.sms_user}">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">SMS密码</label>
                <div class="layui-input-block">
                  <input type="password" name="sms_pass" id="sms_pass" autocomplete="off" placeholder="请输入密码" class="layui-input" value="{$config.sms_pass}">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                  <button class="layui-btn layui-btn-primary layui-border-blue layui-btn-sm" id="smstest-btn">可用性测试</button>
                </div>
              </div>
              <hr class="layui-border-green" style="margin: 20px;">
              <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="edit-submit">修改</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="__PUBLIC__/layui/layui.js"></script>
  <script>
  layui.config({
    base: '__PUBLIC__/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var form = layui.form, $ = layui.$;

    form.on('submit(edit-submit)', function(obj){
      $.post("{:U('Ajax/ajax_config_update')}" , JSON.stringify(obj.field) ,function(d){
          layer.msg(d.msg);
      },"json");
    });

    // 可用性测试
    $('#smstest-btn').on('click', function() {
      $.post("{:U('Ajax/ajax_sms_test')}", JSON.stringify({sms_user: $('#sms_user').val(),sms_pass:$('#sms_pass').val()}),function(d){
        layer.msg(d.msg);
      },"json");
    });
  });
  </script>
</body>
</html>